package Task1.Main;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import Task1.model.DongCat;
import Task1.Threading.*;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main {
    private static final Logger log = LoggerFactory.getLogger(Main.class);
    public static void main(String[] args) {
        PropertyConfigurator.configure("log4j.properties");
        log.info("*******************************");
        log.info("**       Main Started        **");
        log.info("*******************************");
        DongCat dongcat = new DongCat(0, "Đống cát 1");
        Properties prop = new Properties();
        try {
            prop.load(new FileInputStream("AppConfig.properties"));
            log.info("load success Config file {}",prop);
        } catch (FileNotFoundException e) {
            log.error("Exception {}",e);
            return;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            log.error("Exception {}",e);
            return;
        }
        
        int slDen = Integer.parseInt(prop.getProperty("soluong_den"));        
        int slDi = Integer.parseInt(prop.getProperty("soluong_di"));        
        int time_Den = Integer.parseInt(prop.getProperty("time_den_max"));
        int time_Di = Integer.parseInt(prop.getProperty("time_di_max"));
        
        new Thread(new InThread(slDen, dongcat,time_Den)).start();
        new Thread(new OutThread(slDi, dongcat,time_Di)).start();

    }
}
